package com.crm.manager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.common.core.domain.entity.SysUser;
import com.crm.manager.domain.Business;
import com.crm.manager.domain.dto.BatchDTO;
import com.crm.manager.domain.vo.BusinessVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.core.parameters.P;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface BusinessMapper extends BaseMapper<Business> {

    @Select("SELECT * FROM `business_detail` bd RIGHT JOIN business b on bd.business_id = b.id WHERE b.id = #{id}")
    BusinessVO getBusinessDetail(Integer id);


    void batchGain(@Param("ids") List<Integer> ids,@Param("userId") Integer userId, @Param("userName") String userName, @Param("now") LocalDateTime now);

    @Select("select * from sys_user where user_id = #{userId}")
    SysUser queryUserById(Integer userId);

    void batchAssignment(@Param("ids") List<Integer> ids,@Param("userId") Long userId,
                         @Param("userName") String userName,
                         @Param("userName1") String userName1,@Param("now") LocalDateTime now);

    @Update("update business set transfer = 1 where id = #{id}")
    void updateTransfer(Integer id);
}
